window.addEvent('domready', function(){
	/*add user*/  
	$('adduser').onclick = function(event){      
	    $('act').value = 'add';
	    /*if($('name').value == ''){
	    	alert('Please fill the Name field!');
	    	return false;
	    }    */
	    $('wuser').submit();
	};
	
	$('qName').addEvent('keydown', function(event){
	    event = new Event(event);    
	    if (event.key == 'enter') {
	        $('act').value = 'info';
	    	$('wuser').submit();
	    }
	});
	
	['qTeam','qRole'].each(function(item, index){	
		$(item).addEvent('change',queryList);
	});
	
});

/*submit a query form*/
function queryList(){	
    $('act').value = 'info';
    $('wuser').submit();
}

/*delete user*/
function delUser(userId, userName){
	if(window.confirm('Are you sure to delete user: '+userName)){
		$('act').value = 'del';
		$('userid').value = userId;		
		$('wuser').submit();
		
	}else{
		return false;
	}
}

/*edit user info*/
function editUser(userId){
	var request_uri = '/wizard/useredit?ajax=1&t='+(new Date()).getTime();	
	PopBox.pop('loading ...', {loading:true});
	close_redir_url = "/wizard/user";
	new Ajax(request_uri, {
		method: 'get',
		evalScripts : true,
		data: Object.toQueryString({			
			userid: userId
		}),
		onComplete: function(){	
			PopBox.pop(this.response.text);
		}
	}).request();
}
